/**
 * 补录费用

 */
import React from 'react';
import {
    Card, Table, Input, Select, Row, Col, Radio, Button, Tree, Icon, Divider, message, Modal, Tooltip
} from 'antd';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import { Util, dayFormat, timeFormat } from 'tools/index';
import { $http } from 'containers/config/https';
import RangeDatePicker from 'components/rangePicker/index';
import ShowCommonTableModal from 'pages/workstation/component/ShowCommonTableModal';
import ShowDealWithAdvice from './component/ShowDealWithAdvice';
import ShowExecListModal from './component/ShowExecListModal';
import ShowCollectionCostModal from './component/ShowCollectionCostModal';
import CommonPagination from 'components/pagination/index';
import { PAGE_NUM_MORE_STATUS } from 'tools/statusConstants';
import ShowConfirmModal from 'pages/workstation/component/ShowConfirmModal';
import store from 'store';
import moment from 'moment';
import './style/index.less';

const { TreeNode } = Tree;
const Option = Select.Option;
const RadioButton = Radio.Button;
const RadioGroup = Radio.Group;
const confirm = Modal.confirm;
class CollectionCostsPage extends React.Component {
    constructor(props) {
        super(props)
        var patientData = JSON.parse(sessionStorage.getItem('patientData'))
        var userData = JSON.parse(sessionStorage.getItem('userData'))
        this.state = {
            dataSource: [{ indexTable: 0 }],
            total: 0,
            page: 1,
            pageSize: 10,
            leftSize: 200,
            conSize: 100,
            patientData: patientData,
            userData: userData,
            hideMessage: false,
            leftData: [],
            adviceData: [],
            collectionData: [],
            detailData: [],
            groupStatus: '1',
            radioValue: '1',
            size: 'small',
            ids: [],
            adviceIDs: [],
            execIDs: [],
            bodyPartList: [],
            specList: [],
            ordCatCode: '',      //选中医嘱的医嘱项大类代码
            ordStatus: [],
            btnStatus: false,
            adviceWidth: 0,
        }
        this.ordMedItemDesc = React.createRef();
    }

    componentDidMount() {
        this.loadModal()
        this.loadData()
        this.loadCollectionListColumns()//获取左边列表的列数据
        this.loadModuleData()
        this.initData()
        this.loadAdviceColumns()
        this.loadExecutListColumns()
        this.loadChargeDetails()
        this.loadBedData()//获取床号
        this.loadAdviceSelectData()
        this.loadNursingGroup()
    }

    loadModal() {
        this.sunColumns = [
            {
                title: '编码',
                dataIndex: 'medCode',
                width: 100,
                align: 'left',
            }, {
                title: '名称*规格',
                dataIndex: 'medDesc',
                width: 260,
                align: 'left',
            }, {
                title: '库存',
                dataIndex: 'medStock',
                width: 80,
                align: 'left',
            }, {
                title: '单价(元)',
                dataIndex: 'medPrice',
                width: 80,
                align: 'left',
            }, {
                title: '大类',
                dataIndex: 'medCatDesc',
                width: 100,
                align: 'left',
            }, {
                title: '子类',
                dataIndex: 'medSubCatDesc',
                width: 120,
                align: 'left',
            },
            {
                title: '在途数',
                dataIndex: 'resQty',
                width: 80,
                align: 'left',
            }, {
                title: '商品名',
                dataIndex: 'tradeName',
                width: 150,
                align: 'left',
            }, {
                title: '整包装价格',
                dataIndex: 'price',
                width: 100,
                align: 'left',
            },
        ]
    }

    //获取护理分组
    loadNursingGroup() {
        var params = {
            params: [{
                locID: this.state.userData.locID,
            }]
        }
        $http.post('urlDeault', this, {
            code: "01040044",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        nurseGroup: res.result,
                    })
                }
            }
        });
    }

    loadData(page, pageSize, e) {
        var params = {
            params: [{
                locID: this.state.userData.locID,
                userID: this.state.userData.userID,
                hospID: this.state.userData.hospID,
                admStatusCode: this.state.admStatusCode,
                wardID: this.state.wardID,
                medGroupID: this.state.medGroupID,
                levelCode: this.state.levelCode,
                conditionCode: this.state.conditionCode,
                patMessage: this.state.patMessage,
                bedID: this.state.bedID,
                medicalNo: this.state.medicalNo,
                nurseGroupID: this.state.nurseGroupID,
                dateFrom: this.state.admStatusCode == 'D' ? this.state.dateFrom : '',
                dateTo: this.state.admStatusCode == 'D' ? this.state.dateTo : ''
            }],
            // pagination: [{
            //     pageSize: this.state.leftSize,
            //     currentPage: page
            // }]
        }
        $http.post('urlDeault', this, {
            code: "03060004",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        leftData: res.result.data,
                        // admID: !Util.isEmpty(res.result.data) ? res.result.data[0].admID : '',
                        // titleData: !Util.isEmpty(res.result.data) ? res.result.data[0] : '',
                        admStatusData: res.result.admStatusData,
                        wardData: res.result.wardData,
                        medGroupData: res.result.medGroupData,
                        levelData: res.result.levelData,
                        conditionData: res.result.conditionData,
                        total: res.result.totalCount,
                        // patientIDs: !Util.isEmpty(res.result.data) ? [res.result.data[0].admID] : []
                    }, () => {
                        //获取医嘱清单
                        this.loadAdviceList(1)
                        // if (this.state.admID) {
                        //     this.handleAccountBtn()
                        // }
                    })
                }
            }
        });
    }

    changeLeftPageSize(current, pageSize) {
        this.setState({ leftSize: pageSize, pageLeft: current }, () => {
            this.loadAdviceList(current, pageSize);
        });
    }

    onChangeLeft(e) {
        this.setState({ pageLeft: e }, () => {
            this.loadAdviceList(e);
        });
    }

    //获取医嘱清单
    loadAdviceList(page, pageSize, e) {
        var { ordStatusList } = this.state;
        var defaultStatus = ''
        if (!Util.isEmpty(ordStatusList)) {
            for (var i = 0; i < ordStatusList.length; i++) {
                if (!Util.isEmpty(ordStatusList[i].defaultFlag)) {
                    defaultStatus = ordStatusList[i].id
                }
            }
        }
        var params = {
            params: [
                {
                    admID: this.state.admID,
                    priorityID: this.state.priorityID,
                    ordCatID: this.state.ordCatID,
                    searchCode: !Util.isEmpty(this.state.searchCode) ? (this.state.searchCode).replace(/ /g, '') : '',
                    sortCode: this.state.sortCode,
                    dateFrom: this.state.regDateFrom,
                    dateTo: this.state.regDateTo,
                    ordStatusID: this.state.ordStatusID ? this.state.ordStatusID : defaultStatus,
                    ordLocID: this.state.ordLocID,
                    ordDocID: this.state.ordDocID,
                    ordSheetID: this.state.ordSheetID,
                    handlerStatus: this.state.handlerStatus
                }
            ],
            pagination: [{
                pageSize: this.state.size == 'small' ? this.state.leftSize : PAGE_NUM_MORE_STATUS[0].code,
                currentPage: page
            }]
        }
        $http.post('urlDeault', this, {
            code: "03060006",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        adviceData: res.result.data,
                        adviceTotal: res.result.totalCount,
                        search: 'search',
                        pageLeft: page,
                        loading: false
                    })
                }
            }
        });
    }

    loadChargeDetails() {
        let data = {
            params: [{
                compontName: "chargeDetails",
                type: "C",
            }]
        }
        $http.post('urlDeault', this, {
            code: "01040073",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    var columns = res.result.C;
                    var dynColumns = []
                    for (var i = 0; i < columns.length; i++) {
                        dynColumns.push({
                            title: columns[i].title,
                            dataIndex: columns[i].dataIndex,
                            width: parseInt(columns[i].width),
                            align: columns[i].align || 'center'
                        })
                    }
                    this.setState({
                        chargeColumns: dynColumns,
                        chargeWidth: res.totalWidth
                    })
                    this.props.hanlderThis.setState({
                        reload: false,
                    })
                }
            }
        })
    }

    loadExecutListColumns() {
        let data = {
            params: [{
                compontName: "executionList",
                type: "C",
            }]
        }
        $http.post('urlDeault', this, {
            code: "01040073",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    var columns = res.result.C;
                    var dynColumns = []
                    for (var i = 0; i < columns.length; i++) {
                        dynColumns.push({
                            title: columns[i].title,
                            dataIndex: columns[i].dataIndex,
                            width: parseInt(columns[i].width),
                            align: columns[i].align || 'center'
                        })
                    }
                    this.setState({
                        execuseColumns: dynColumns,
                        execuseWidth: res.totalWidth
                    })
                    this.props.hanlderThis.setState({
                        reload: false,
                    })
                }
            }
        })
    }

    loadAdviceColumns() {
        let data = {
            params: [{
                compontName: "adviceListPage",
                type: "C",
            }]
        }
        $http.post('urlDeault', this, {
            code: "01040073",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    var columns = res.result.C;
                    var dynColumns = []
                    for (var i = 0; i < columns.length; i++) {
                        if (columns[i].dataIndex == 'adviceList') {
                            dynColumns.push({
                                title: columns[i].title,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center',
                                render: (text, data, index) => {
                                    return <span>
                                        <span style={{ color: '#1999db' }}>{data.ordDesc ? <span>{data.ordDesc}</span> : null}</span>
                                        <span>{data.ordFreqDesc ? <span>【{data.ordFreqDesc}】</span> : null}</span>
                                        <span>{data.ordDose ? <span>【{data.ordDose + data.ordDoseUnitDesc}】</span> : null}</span>
                                        <span>{data.ordUsageDesc ? <span>【{data.ordUsageDesc}】</span> : null}</span>
                                    </span>
                                }
                            })
                        } else {
                            dynColumns.push({
                                title: columns[i].title,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center'
                            })
                        }
                    }
                    this.setState({
                        adviceColumns: dynColumns,
                        adviceWidth: res.totalWidth
                    })
                    this.props.hanlderThis.setState({
                        reload: false,
                    })
                }
            }
        })
    }

    initData() {
        let data = {
            params: [{
                compontName: "addAdviceListPage",
                type: "C",
            }]
        }
        $http.post('urlDeault', this, {
            code: "01040073",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    var columns = res.result.C;
                    var dynColumns = []
                    for (var i = 0; i < columns.length; i++) {
                        if (columns[i].dataIndex == 'ordMedItemDesc') {
                            dynColumns.push({
                                title: columns[i].title,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center',
                                render: (text, data, index) => {
                                    data.tabIndex = index + 1
                                    return <Input style={{ width: '98%' }} id={"name-input" + index}
                                        onKeyDown={this.showCommonTableModal.bind(this, index)} allowClear={true}
                                        autoFocus ref={this.ordMedItemDesc}
                                        value={data.ordMedItemDesc ? data.ordMedItemDesc : this.state.changeValue}
                                        // value={this.state.changeValue?this.state.changeValue:data.ordMedItemDesc}
                                        onChange={this.handleSearchInput.bind(this, 'ordMedItemDesc', index)}
                                    />
                                }
                            })
                        } else if (columns[i].dataIndex == 'ordQtyUomID') {
                            dynColumns.push({
                                title: columns[i].title,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center',
                                render: (text, data, index) => {
                                    var qtyUnitListOption = []
                                    // var { qtyUnitList } = this.state;
                                    var qtyUnitList = data.qtyUnitList;
                                    var newData = []
                                    qtyUnitList && qtyUnitList.map((item, index) => {
                                        qtyUnitListOption.push(<Option key={index} code={item.price} value={item.unitID} qtyMolecule={item.molecule}
                                            onClick={this.handleOnSelectColumns.bind(this, 'ordQtyUomID', index, data)}
                                            qtyDenominator={item.denominator} price={item.price}>{item.unitDesc}</Option>)
                                    })
                                    return <Select onChange={(e, option) => this.changeCommonSelect('ordQtyUomID', index, data, e, option)} style={{ width: '98%' }}
                                        showArrow={false}
                                        onSelect={this.handleOnSelectColumns.bind(this, 'ordQtyUomID', index, data)}
                                        value={data.ordQtyUomID}>{qtyUnitListOption}</Select>
                                }
                            })
                        } else if (columns[i].dataIndex == 'ordbodyPartID') {//部位
                            dynColumns.push({
                                title: columns[i].title,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center',
                                render: (text, data, index) => {
                                    var bodyPartListOption = []
                                    // var { qtyUnitList } = this.state;
                                    var bodyPartList = data.bodyPartList;

                                    bodyPartList && bodyPartList.map((item, index) => {
                                        bodyPartListOption.push(<Option key={index} value={item.id} partid={item.id} descripts={item.descripts}
                                            mutexflag={item.mutexFlag} ordprice={Number(item.ordPrice)}
                                        >{item.descripts}</Option>)
                                    })

                                    return <Select onChange={this.changeBodyPartRadioSelect.bind(this, 'ordbodyPartID', index, data)} style={{ width: '98%' }}
                                        showArrow={false} allowClear
                                        onSelect={this.handleOnSelectColumns.bind(this, 'ordbodyPartID', index, data)}
                                        value={data.ordbodyPartID}>{bodyPartListOption}</Select>
                                }
                            })
                        } else if (columns[i].dataIndex == 'ordSpecID') {//标本
                            dynColumns.push({
                                title: columns[i].title,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center',
                                render: (text, data, index) => {
                                    var specListOption = []
                                    var specList = data.specList;

                                    specList && specList.map((item, index) => {
                                        specListOption.push(<Option key={index} value={item.id} partid={item.id} descripts={item.descripts}
                                            mutexflag={item.mutexFlag} ordprice={Number(item.ordPrice)}
                                            onClick={this.handleOnSelectColumns.bind(this, 'ordSpecID', index, data)}
                                        >{item.descripts}</Option>)
                                    })

                                    return <Select onChange={(e, option) => this.changeCommonSelect('ordSpecID', index, data, e, option)} style={{ width: '98%' }}
                                        showArrow={false}
                                        onSelect={this.handleOnSelectColumns.bind(this, 'ordSpecID', index, data)}
                                        value={data.ordSpecID}>{specListOption}</Select>
                                }
                            })
                        } else if (columns[i].dataIndex == 'ordPrice') {
                            dynColumns.push({
                                title: columns[i].title,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center'
                            })
                        } else if (columns[i].dataIndex == 'ordQty') {
                            dynColumns.push({
                                title: columns[i].title,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center',
                                render: (text, data, index) => {
                                    return <Input value={data.ordQty}
                                        onChange={this.commonInput.bind(this, 'ordQty', index, data)} />
                                }
                            })
                        } else if (columns[i].dataIndex == 'totalPrice') {
                            dynColumns.push({
                                title: columns[i].title,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center',
                                render: (text, data, index) => {
                                    return <span>{(!Util.isEmpty(data.ordPrice) && !Util.isEmpty(data.ordQty) ?
                                        (parseFloat(data.ordPrice) * parseFloat(data.ordQty)).toFixed(2) : 0)}</span>
                                }
                            })
                        } else {
                            dynColumns.push({
                                title: columns[i].title,
                                dataIndex: columns[i].dataIndex,
                                width: parseInt(columns[i].width),
                                align: columns[i].align || 'center'
                            })
                        }
                    }
                    this.setState({
                        feeColumns: dynColumns,
                        feeWidth: res.feeWidth
                    })
                    this.props.hanlderThis.setState({
                        reload: false,
                    })
                }
            }
        })
    }

    handleOnSelectColumns(name, index, data, e) {
        if (name == 'ordbodyPartID') {
            this.state.dataSource[index][name] = [e]
        } else {
            this.state.dataSource[index][name] = e
        }
        this.setState({})
    }

    commonInput(name, index, data, e) {
        this.state.dataSource[index][name] = e.target.value
        this.setState({})
    }

    changeCommonSelect(name, index, data, e, option) {
        this.state.dataSource[index][name] = e
        this.setState({})
    }

    changeBodyPartRadioSelect(name, index, data, e, option) {
        var price = this.state.dataSource[index]['ordNewPrice'] || 1//清空价格，不会将部位价格置空
        this.state.dataSource[index][name] = [e]
        this.state.dataSource[index]['ordPrice'] = option ? option.props.ordprice : price
        this.setState({})
    }

    loadAdviceSelectData() {
        const { admID } = this.state;
        if (!admID) return;
        var params = {
            params: [
                {
                    admID,
                    priorityFlag: 'Y',
                    ordCatFlag: 'Y',
                    sortFlag: 'Y',
                    ordStatusFlag: 'Y',
                    ordLocFlag: 'Y',
                    ordDocFlag: 'Y',
                    ordSheetFlag: 'Y',
                    handlerStatusFlag: 'Y'
                }
            ]
        }
        $http.post('urlDeault', this, {
            code: '03060007',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    var defaultStatus = res.data.handlerStatusList
                    var handlerStatus = ''
                    if (!Util.isEmpty(defaultStatus)) {
                        for (var i = 0; i < defaultStatus.length; i++) {
                            if (defaultStatus[i].defaultFlag && defaultStatus[i].defaultFlag == 'Y') {
                                handlerStatus = defaultStatus[i].code
                            }
                        }
                    }
                    this.setState({
                        ordCatList: res.data.ordCatList,//医嘱分类
                        ordDocList: res.data.ordDocList,//开单医生
                        ordLocList: res.data.ordLocList,//开单科室
                        ordStatusList: res.data.ordStatusList,//医嘱状态
                        priorityList: res.data.priorityList,//医嘱类型
                        sortList: res.data.sortList,//排序
                        ordSheetList: res.data.ordSheetList,//医嘱单
                        handlerStatusList: res.data.handlerStatusList,//医嘱单
                        handlerStatus: handlerStatus
                    })
                }
            }
        });
    }

    changeConPageSize(current, pageSize) {
        this.setState({ conSize: pageSize, pageCon: current }, () => {
            this.loadAdviceCollectionList(current, pageSize);
        });
    }

    onChangeCon(e) {
        this.setState({ pageCon: e }, () => {
            this.loadAdviceCollectionList(e);
        });
    }

    loadAdviceCollectionList(page, pageSize, e) {
        var params = {
            params: [{
                ordID: this.state.ordAdviceID,
                dateFrom: this.state.dateFrom,
                dateTo: this.state.dateTo
            }],
            pagination: [{
                pageSize: this.state.conSize,
                currentPage: page
            }]
        }
        $http.post('urlS', this, {
            code: '03060022',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        collectionData: res.result.data,
                        conTotal: res.result.totalCount,
                        collSearch: 'search',
                        pageCon: page,
                    })
                }
            }
        })
    }

    loadExecList() {
        var params = {
            params: [{
                ordExecID: this.state.ordExecID,
            }]
        }
        $http.post('urlS', this, {
            code: '03060023',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        detailData: res.result
                    })
                }
            }
        })
    }

    loadModuleData() {
        var params = {
            params: [{
                orderTemplTypeFlag: '1'
            }]
        }
        $http.post('urlS', this, {
            code: '03050017',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        moduleData: res.orderTemplType,
                        defaultTemplTypeID: res.defaultTemplTypeID
                    }, () => {
                        this.loadTemplateData()
                    })
                }
            }
        })
    }

    loadCollectionListColumns() {
        let data = {
            params: [{
                compontName: 'CollectionList',
                type: 'C',
            }]
        }
        $http.post('urlDeault', this, {
            code: '01040073',
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    var columns = res.result.C;
                    var dynColumns = []
                    for (var i = 0; i < columns.length; i++) {
                        dynColumns.push({
                            title: columns[i].title,
                            dataIndex: columns[i].dataIndex,
                            width: parseInt(columns[i].width),
                            align: columns[i].align || 'center'
                        })
                    }
                    this.setState({
                        leftColumns: dynColumns,
                        leftWidth: res.totalWidth
                    })
                    this.props.hanlderThis.setState({
                        reload: false,
                    })
                }
            }
        })
    }

    /**
     * @shizi: noCheckDetailFlag为Y不返回dataList明细数据，解决数据过多时接口返回很慢
     * Create 2021-06-13
     */
    loadTemplateData() {
        var params = {
            params: [{
                input: this.state.templateInput,
                templetCatCode: '01',
                templetTypeID: this.state.radioValue ? this.state.radioValue : this.state.defaultTemplTypeID,
                noCheckDetailFlag: 'Y'
            }],
        }
        $http.post('urlDeault', this, {
            code: '03050023',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        templateData: res.result
                    })
                }
            }
        });
    }

    loadBedData() {
        var params = {
            params: [{
                locID: this.state.userData.locID,
                admStatusCode: this.state.admStatusCode,
                wardID: this.state.wardID
            }]
        }
        $http.post('urlDeault', this, {
            code: '03060005',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        bedData: res.data
                    })
                }
            }
        });
    }

    loadSelectData(value, page, pageSize, search) {
        var params = {
            params: [{
                admID: this.state.admID,
                searchCode: value ? value.replace(/^\s*|\s*$/g, '') :
                    (this.state.changeValue ? this.state.changeValue.replace(/^\s*|\s*$/g, '') : ''),
                logonLocID: this.state.userData.locID,
                userID: this.state.userData.userID,
                groupID: this.state.userData.groupID,
                hospID: this.state.userData.hospID,
                judgeFlag: 'Y'
            }],
            pagination: [{
                pageSize: this.state.pageSize,
                currentPage: page
            }]

        }
        $http.post('urlDeault', this, {
            code: '03050019',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.state.selectData = res.result.data.length > 0 ? res.result.data : []
                    this.setState({
                        total: res.result.totalCount,
                        rowMedID: res.result.data ? res.result.data[0].medID : (res.result.data ? res.result.data[0].ordSetID : ''),
                        search: search
                    })
                }
            }
        });
    }

    //列修改为input框，change事件处理
    handleSearchInput(name, index, e) {
        var { dataSource } = this.state;
        let top = document.getElementById('name-input' + index).getBoundingClientRect().top + 40;
        let left = document.getElementById('name-input' + index).getBoundingClientRect().left + 'px';
        let windowHeight = window.innerHeight;
        if ((top + 360) > windowHeight) {
            top = top - 330 - 80 + 'px';
        }
        var value = e.target.value;
        //change名称规格的时候，讲关联关系去除
        if (Util.isEmpty(value)) {
            this.state.dataSource[index] = { tabIndex: index + 1 }
        }
        this.state.dataSource[index].ordMedItemDesc = value
        this.setState({
            changeValue: value,
            indexTab: index,
            top: top,
            left: left,
        })
        if (value.length >= 2) {
        } else {
            this.setState({
                selectData: [],
                total: 0,
                page: 1,
            })
        }
    }

    showCommonTableModal(index, e) {
        if (e.keyCode == '13') {
            this.setState({
                isShowCommonTableModal: true,
                indexTable: index//删除一条空数据，重新添加
            }, () => {
                this.child.showModal();
                this.loadSelectData(this.state.changeValue, '', '')
            })
        }
    }

    //分页切换
    changePageSize(current, pageSize) {
        this.setState({ pageSize: pageSize, page: current }, () => {
            this.loadSelectData('', current, pageSize, 'search');
        });
    }

    //分页切换
    onChange(e) {
        this.setState({ page: e }, () => {
            this.loadSelectData('', e, '');
        });
    }

    rowClick = (record, index) => {
        this.setState({
            visible: false,
            rowData: record.medDesc,
            ordSpecID: record.ordSpecID,
            selectData: [],
            focusStatus: true,//焦点标识
            visStatus: false,
        }, () => {
            this.child.handleCancel();
            this.loadTableData('', record, index)
        })
    }

    //获取列表行数据
    loadTableData(status, record, data) {
        var that = this;
        var date = new Date();
        var { dataSource } = this.state;
        var source = []
        for (var i = 0; i < dataSource.length; i++) {
            if (Util.isEmpty(dataSource[i].ordID) && !Util.isEmpty(dataSource[i].medID)) {
                source.push(dataSource[i])
            }
        }
        var params = {
            params: [{
                admID: this.state.admID,
                indexID: source ? source.length : 0,
                orders: [{
                    medID: status == 'temp' ? data.props.nodeId : (status == 'batch' ? (record[0].ordSetID ? '' : record[0].medID) : record.medID),
                    ordSetID: status == 'temp' ? data.props.ordSetID : (status == 'batch' ? record[0].ordSetID : record.ordSetID || '')
                }]
            }]
        }
        $http.post('urlDeault', this, {
            code: '03060020',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    if (res.errorData.length == 1) {
                        message.error(res.errorData[0].errorMessage)
                        return
                    }
                    if (res.errorData.length > 1) {
                        this.setState({
                            isShowConfirmModal: true,
                            errorData: res.errorData,
                            confirmData: res.confirmData,
                        })
                        return
                    }
                    if (res.confirmData.length > 0) {
                        confirm({
                            title: '确认',
                            content: res.confirmData[0].errorMessage,
                            okText: that.state.userData.language == 'EN' ? 'Ok' : '确定',
                            cancelText: that.state.userData.language == 'EN' ? 'cancel' : '取消',
                            onOk() {
                                that.state.dataSource[that.state.indexTable]['ordMedItemDesc'] = res.data[0].defaultData.ordDesc,
                                    that.state.dataSource[that.state.indexTable]['ordDose'] = res.data[0].defaultData.ordDose,
                                    that.state.dataSource[that.state.indexTable]['ordDoseUnitID'] = res.data[0].defaultData.ordDoseUnitID,
                                    // that.state.dataSource[that.state.indexTable]['ordFreqID'] = res.data[0].defaultData.ordFrequenceID,
                                    that.state.dataSource[that.state.indexTable]['ordFreqID'] = res.data[0].defaultData.ordFreqID,
                                    that.state.dataSource[that.state.indexTable]['ordFreqDesc'] = res.data[0].defaultData.ordFreqDesc,
                                    that.state.dataSource[that.state.indexTable]['ordUsageDesc'] = res.data[0].defaultData.ordUsageDesc,
                                    that.state.dataSource[that.state.indexTable]['ordUsageID'] = res.data[0].defaultData.ordUsageID,
                                    that.state.dataSource[that.state.indexTable]['ordDurQty'] = res.data[0].defaultData.ordDurQty,
                                    that.state.dataSource[that.state.indexTable]['ordNewPrice'] = res.data[0].defaultData.ordPrice,
                                    that.state.dataSource[that.state.indexTable]['ordDurationID'] = res.data[0].defaultData.ordDurationID,
                                    that.state.dataSource[that.state.indexTable]['ordSkinTestUsageID'] = res.data[0].defaultData.ordSkinTestUsageID,
                                    that.state.dataSource[that.state.indexTable]['ordSkinTestUsageDesc'] = res.data[0].defaultData.ordSkinTestUsageDesc,
                                    that.state.dataSource[that.state.indexTable]['ordQty'] = res.data[0].defaultData.ordQty,
                                    that.state.dataSource[that.state.indexTable]['ordQtyUomID'] = res.data[0].defaultData.ordQtyUomID,
                                    that.state.dataSource[that.state.indexTable]['ordbodyPartID'] = res.data[0].defaultData.ordbodyPartID,
                                    that.state.dataSource[that.state.indexTable]['ordPrice'] = res.data[0].defaultData.ordPrice,
                                    that.state.dataSource[that.state.indexTable]['ordSkinTestFlag'] = res.data[0].defaultData.ordSkinTestFlag,
                                    that.state.dataSource[that.state.indexTable]['testFlag'] = res.data[0].defaultData.ordSkinTestFlag,
                                    that.state.dataSource[that.state.indexTable]['ordSkinTestWayID'] = res.data[0].defaultData.ordSkinTestWayID,
                                    that.state.dataSource[that.state.indexTable]['ordRecLocID'] = res.data[0].defaultData.ordRecLocID,
                                    that.state.dataSource[that.state.indexTable]['ordPriorityID'] = res.data[0].defaultData.ordPriorityID,
                                    that.state.dataSource[that.state.indexTable]['medDesca'] = res.data[0].defaultData.ordDesca,
                                    that.state.dataSource[that.state.indexTable]['ordAdmReasonID'] = res.data[0].defaultData.ordAdmReasonID,
                                    that.state.dataSource[that.state.indexTable]['ordSeqNo'] = parseInt(that.state.indexTable) + 1,
                                    that.state.dataSource[that.state.indexTable]['ordDate'] = res.data[0]?.defaultData?.ordDate || res.data[0]?.defaultData?.date || moment(date).format(dayFormat),
                                    that.state.dataSource[that.state.indexTable]['ordTime'] = res.data[0]?.defaultData?.ordTime || res.data[0]?.defaultData?.time || moment(date).format(timeFormat),
                                    that.state.dataSource[that.state.indexTable]['ordStartDate'] = res.data[0]?.defaultData?.ordStartDate || res.data[0]?.defaultData?.date || moment(date).format(dayFormat),
                                    that.state.dataSource[that.state.indexTable]['ordStartTime'] = res.data[0]?.defaultData?.ordStartTime || res.data[0]?.defaultData?.time || moment(date).format(timeFormat),
                                    that.state.dataSource[that.state.indexTable]['ordNote'] = res.data[0].defaultData.ordNote,
                                    that.state.dataSource[that.state.indexTable]['medID'] = status == 'temp' ? data.props.nodeId : (status == 'batch' ? record[0].medID : record.medID),
                                    that.state.dataSource[that.state.indexTable]['ordMedItemID'] = status == 'temp' ? data.props.nodeId : (status == 'batch' ? record[0].medID : record.medID),
                                    that.state.dataSource[that.state.indexTable]['ordTypeCode'] = res.data[0].defaultData.ordTypeCode,
                                    that.state.dataSource[that.state.indexTable]['ordSpecID'] = res.data[0].defaultData.ordSpecID,
                                    that.state.dataSource[that.state.indexTable]['ordToalCountO'] = res.data[0].defaultData.ordToalCountO,
                                    that.state.dataSource[that.state.indexTable]['ordToalCountI'] = res.data[0].defaultData.ordToalCountI,
                                    that.state.dataSource[that.state.indexTable]['frequency'] = res.data[0].defaultData.frequency,
                                    that.state.dataSource[that.state.indexTable]['cycleDays'] = res.data[0].defaultData.cycleDays,
                                    that.state.dataSource[that.state.indexTable]['ordStageID'] = res.data[0].defaultData.ordStageID,
                                    that.state.dataSource[that.state.indexTable]['intervalDays'] = res.data[0].defaultData.intervalDays,
                                    that.state.dataSource[that.state.indexTable]['duraFactor'] = res.data[0].defaultData.duraFactor,
                                    that.state.dataSource[that.state.indexTable]['ordSkinTestFlagValue'] = res.data[0].defaultData.ordSkinTestFlagValue,
                                    that.state.dataSource[that.state.indexTable]['ordEMFlagValue'] = res.data[0].defaultData.ordEMFlagValue,
                                    that.state.dataSource[that.state.indexTable]['ordEMFlag'] = res.data[0].defaultData.ordEMFlag,
                                    that.state.dataSource[that.state.indexTable]['testEMFlag'] = res.data[0].defaultData.ordEMFlag,
                                    that.state.dataSource[that.state.indexTable]['ordSkinTestFlag'] = res.data[0].defaultData.ordSkinTestFlag,
                                    that.state.dataSource[that.state.indexTable]['testFlag'] = res.data[0].defaultData.ordSkinTestFlag,
                                    that.state.dataSource[that.state.indexTable]['doseDenominator'] = res.data[0].defaultData.doseDenominator,
                                    that.state.dataSource[that.state.indexTable]['doseMolecule'] = res.data[0].defaultData.doseMolecule,
                                    that.state.dataSource[that.state.indexTable]['qtyMolecule'] = res.data[0].defaultData.qtyMolecule,
                                    that.state.dataSource[that.state.indexTable]['qtyDenominator'] = res.data[0].defaultData.qtyDenominator,
                                    that.state.dataSource[that.state.indexTable]['ordPriorityExtID'] = res.data[0].defaultData.ordPriorityExtID,
                                    that.state.dataSource[that.state.indexTable]['ordPriorityExtDesc'] = res.data[0].defaultData.ordPriorityExtDesc,
                                    that.state.dataSource[that.state.indexTable]['ordMessage'] = res.data[0].defaultData.ordMessage,
                                    that.state.dataSource[that.state.indexTable]['qtyUnitList'] = res.data[0].dataList.qtyUnitList,
                                    that.state.dataSource[that.state.indexTable]['bodyPartList'] = res.data[0].dataList.bodyPartList,
                                    that.state.dataSource[that.state.indexTable]['specList'] = res.data[0].dataList.specList,
                                    that.setState({
                                        ordMessage: res.data[0].defaultData.ordMessage,
                                        tableData: res.data[0].defaultData,
                                        qtyUnitList: res.data[0].dataList.qtyUnitList,//数量单位
                                        changeValue: undefined,
                                    })
                                // that.deleteNullData()
                            },
                            onCancel() {
                                console.log('Cancel');
                            },
                        });
                    } else {
                        //双击医嘱项，根据index，渲染对应行的默认数据
                        this.state.dataSource[this.state.indexTable]['ordMedItemDesc'] = res.data[0].defaultData.ordDesc,
                            this.state.dataSource[this.state.indexTable]['ordDose'] = res.data[0].defaultData.ordDose,
                            this.state.dataSource[this.state.indexTable]['ordDoseUnitID'] = res.data[0].defaultData.ordDoseUnitID,
                            // this.state.dataSource[this.state.indexTable]['ordFreqID'] = res.data[0].defaultData.ordFrequenceID,
                            this.state.dataSource[this.state.indexTable]['ordFreqID'] = res.data[0].defaultData.ordFreqID,
                            that.state.dataSource[that.state.indexTable]['ordFreqDesc'] = res.data[0].defaultData.ordFreqDesc,
                            that.state.dataSource[that.state.indexTable]['ordUsageDesc'] = res.data[0].defaultData.ordUsageDesc,
                            this.state.dataSource[this.state.indexTable]['ordUsageID'] = res.data[0].defaultData.ordUsageID,
                            this.state.dataSource[this.state.indexTable]['ordDurQty'] = res.data[0].defaultData.ordDurQty,
                            this.state.dataSource[this.state.indexTable]['ordDurationID'] = res.data[0].defaultData.ordDurationID,
                            this.state.dataSource[this.state.indexTable]['ordbodyPartID'] = res.data[0].defaultData.ordbodyPartID,
                            this.state.dataSource[this.state.indexTable]['ordQty'] = res.data[0].defaultData.ordQty,
                            this.state.dataSource[this.state.indexTable]['ordQtyUomID'] = res.data[0].defaultData.ordQtyUomID,
                            this.state.dataSource[this.state.indexTable]['ordPrice'] = res.data[0].defaultData.ordPrice,
                            this.state.dataSource[this.state.indexTable]['ordSkinTestFlag'] = res.data[0].defaultData.ordSkinTestFlag,
                            this.state.dataSource[this.state.indexTable]['testFlag'] = res.data[0].defaultData.ordSkinTestFlag,
                            this.state.dataSource[this.state.indexTable]['ordSkinTestWayID'] = res.data[0].defaultData.ordSkinTestWayID,
                            this.state.dataSource[this.state.indexTable]['ordRecLocID'] = res.data[0].defaultData.ordRecLocID,
                            this.state.dataSource[this.state.indexTable]['ordPriorityID'] = res.data[0].defaultData.ordPriorityID,
                            this.state.dataSource[this.state.indexTable]['ordStageID'] = res.data[0].defaultData.ordStageID,
                            this.state.dataSource[this.state.indexTable]['medDesca'] = res.data[0].defaultData.ordDesca,
                            this.state.dataSource[this.state.indexTable]['ordSkinTestUsageID'] = res.data[0].defaultData.ordSkinTestUsageID,
                            this.state.dataSource[this.state.indexTable]['ordSkinTestUsageDesc'] = res.data[0].defaultData.ordSkinTestUsageDesc,
                            this.state.dataSource[this.state.indexTable]['ordEMFlag'] = res.data[0].defaultData.ordEMFlag,
                            this.state.dataSource[this.state.indexTable]['testEMFlag'] = res.data[0].defaultData.ordEMFlag,
                            this.state.dataSource[this.state.indexTable]['ordSkinTestFlag'] = res.data[0].defaultData.ordSkinTestFlag,
                            this.state.dataSource[this.state.indexTable]['testFlag'] = res.data[0].defaultData.ordSkinTestFlag,
                            this.state.dataSource[this.state.indexTable]['ordAdmReasonID'] = res.data[0].defaultData.ordAdmReasonID,
                            this.state.dataSource[this.state.indexTable]['ordSeqNo'] = parseInt(this.state.indexTable) + 1,
                            this.state.dataSource[this.state.indexTable]['ordDate'] = res.data[0].defaultData.ordDate ?
                                moment(res.data[0].defaultData.ordDate).format(dayFormat) : moment(date).format(dayFormat),
                            this.state.dataSource[this.state.indexTable]['ordTime'] = res.data[0].defaultData.ordTime ?
                                moment(res.data[0].defaultData.ordTime).format(timeFormat) : moment(date).format(timeFormat),
                            this.state.dataSource[this.state.indexTable]['ordStartDate'] = moment(date).format(dayFormat),
                            this.state.dataSource[this.state.indexTable]['ordStartTime'] = moment(date).format(timeFormat),
                            this.state.dataSource[this.state.indexTable]['ordNote'] = res.data[0].defaultData.ordNote,
                            this.state.dataSource[this.state.indexTable]['medID'] = status == 'temp' ? data.props.nodeId : (status == 'batch' ? record[0].medID : record.medID),
                            this.state.dataSource[this.state.indexTable]['ordMedItemID'] = status == 'temp' ? data.props.nodeId : (status == 'batch' ? record[0].medID : record.medID),
                            this.state.dataSource[this.state.indexTable]['ordTypeCode'] = res.data[0].defaultData.ordTypeCode,
                            this.state.dataSource[this.state.indexTable]['ordSpecID'] = res.data[0].defaultData.ordSpecID,
                            this.state.dataSource[this.state.indexTable]['ordSkinTestFlagValue'] = res.data[0].defaultData.ordSkinTestFlagValue,
                            this.state.dataSource[this.state.indexTable]['ordEMFlagValue'] = res.data[0].defaultData.ordEMFlagValue,
                            this.state.dataSource[this.state.indexTable]['ordToalCountO'] = res.data[0].defaultData.ordToalCountO,
                            this.state.dataSource[this.state.indexTable]['ordToalCountI'] = res.data[0].defaultData.ordToalCountI,
                            this.state.dataSource[this.state.indexTable]['frequency'] = res.data[0].defaultData.frequency,
                            this.state.dataSource[this.state.indexTable]['cycleDays'] = res.data[0].defaultData.cycleDays,
                            this.state.dataSource[this.state.indexTable]['intervalDays'] = res.data[0].defaultData.intervalDays,
                            this.state.dataSource[this.state.indexTable]['duraFactor'] = res.data[0].defaultData.duraFactor,
                            this.state.dataSource[this.state.indexTable]['doseDenominator'] = res.data[0].defaultData.doseDenominator,
                            this.state.dataSource[this.state.indexTable]['doseMolecule'] = res.data[0].defaultData.doseMolecule,
                            this.state.dataSource[this.state.indexTable]['qtyMolecule'] = res.data[0].defaultData.qtyMolecule,
                            this.state.dataSource[this.state.indexTable]['qtyDenominator'] = res.data[0].defaultData.qtyDenominator,
                            this.state.dataSource[this.state.indexTable]['ordPriorityExtDesc'] = res.data[0].defaultData.ordPriorityExtDesc,
                            this.state.dataSource[this.state.indexTable]['ordPriorityExtID'] = res.data[0].defaultData.ordPriorityExtID,
                            this.state.dataSource[this.state.indexTable]['qtyUnitList'] = res.data[0].dataList.qtyUnitList,
                            this.state.dataSource[this.state.indexTable]['bodyPartList'] = res.data[0].dataList.bodyPartList,
                            this.state.dataSource[this.state.indexTable]['specList'] = res.data[0].dataList.specList,
                            this.setState({
                                tableData: res.data[0].defaultData,
                                ordMessage: res.data[0].defaultData.ordMessage,
                                qtyUnitList: res.data[0].dataList.qtyUnitList,//数量单位
                                changeValue: undefined,
                            })
                    }
                }
            }
        });
    }

    // 操作弹框
    onClickRowPublic = (record, index) => {
        return {
            onClick: () => {
                if (Util.isEmpty(record.medStock) && record.orderType == 'D') {
                    message.error('库存不足，无法添加')
                    return
                }
                this.setState({
                    rowMedID: record.medID || record.ordSetID
                }, () => {
                    this.rowClick(record, index)
                })
            }
        }
    }

    setRowClassNamePublic = (record) => {
        return (record.medID || record.ordSetID) === this.state.rowMedID ? 'clickRowStyle' : '';
    }

    onAdviceClickRow = (record, index) => {
        return {
            onClick: () => {
                this.state.adviceIDs = [record.ordID]

                if (record.objStatus === 'Y' && record.ordHandleStatus === '已处理') {
                    // var obj={};
                    // obj.ordName=record.ordDesc;
                    // obj.status=record.objStatus;
                    var strMessage = record.ordDesc + '已经领过药了，需退还药品才不计费!';
                    this.state.ordStatus = [strMessage];
                }
                this.setState({
                    ordAdviceID: record.ordID,
                    takeFlag: record.takeFlag,
                    ordMedDescName: record.ordDesc,
                    ordCatCode: record.orderCatCode,
                    detailData: [],
                    subOrderFlag: record.subOrderFlag,
                    execIDs: []
                }, () => {
                    this.loadAdviceCollectionList(1)//获取医嘱执行记录
                })
            }
        }
    }

    countDown = () => {
        let secondsToGo = 3;
        const modal = Modal.success({
            title: '执行成功！',
            content: `将于 ${secondsToGo} 秒后关闭窗口.`,
        });
        const timer = setInterval(() => {
            secondsToGo -= 1;
            modal.update({
                content: `将于 ${secondsToGo} 秒后关闭窗口.`,
            });
        }, 1000);
        setTimeout(() => {
            clearInterval(timer);
            modal.destroy();
        }, secondsToGo * 1000);
    }

    //取药执行记录
    handleMedicleMessage() {
        var params = {
            params: [{
                userID: this.state.userData.userID,
                ordID: this.state.ordAdviceID
            }]
        }
        $http.post('urlDeault', this, {
            code: '03050271',
            data: params,
            success: (res) => {
                if (res.errorCode == '0') {
                    // message.success('操作成功！')
                    this.countDown();
                    this.loadAdviceCollectionList(1)
                }
            }
        })
    }

    setAdviceRowClassName = (record) => {
        // return record.ordID === this.state.ordAdviceID ? 'clickRowStyle' : '';
        if (record.ordID === this.state.ordAdviceID) {
            return 'clickRowStyle'
        } else if (record.supplement == 'Y') {//补录
            return 'clickSupplemented'
        } else if (record.supplemented == 'Y') {//参照补录
            return 'clickSupplement'
        } else if (record.supplementeds == 'Y') {
            return 'clickSupplements'
        }
    }

    onExecClickRow = (record, index) => {
        return {
            onClick: () => {
                this.state.execIDs = [record.ordExecID]
                this.setState({
                    ordExecID: record.ordExecID,
                }, () => {
                    this.loadExecList()//获取费用明细
                })
            }
        }
    }

    setExecRowClassName = (record) => {
        return record.ordExecID === this.state.ordExecID ? 'clickRowStyle' : '';
    }

    handleOnKeydown(e) {
        var e = window.event || e;
        let scroll_height = 50;
        let id = '';
        let oneArr = this.state.selectData && this.state.selectData.length > 0 ? this.state.selectData : [];
        switch (e.keyCode) {
            case 13:
                if (this.state.rowMedID) {
                    let obj = {}
                    for (var i = 0; i < oneArr.length; i++) {
                        if ((oneArr[i].medID || oneArr[i].ordSetID) === this.state.rowMedID) {
                            obj = i > 0 ? oneArr[i] : oneArr[0];
                            break;
                        }
                    }
                    if (Util.isEmpty(obj)) {
                        message.error('无可选择的医嘱项')
                        return
                    }
                    if (Util.isEmpty(obj.medStock) && obj.orderType == 'D') {
                        message.error('库存不足，无法添加！')
                        return
                    }
                    this.rowClick(obj);
                } else {
                    message.info('请选择一条需要操作的数据')
                }
                break;
            case 38: //上
                if (this.state.rowMedID) {
                    for (var i = 0; i < oneArr.length; i++) {
                        if ((oneArr[i].medID || oneArr[i].ordSetID) === this.state.rowMedID) {
                            id = i > 0 ? (oneArr[i - 1].medID || oneArr[i - 1].ordSetID) : (oneArr[0].medID || oneArr[0].ordSetID);
                            break;
                        }
                    }
                    this.setState({ rowMedID: id }, () => {
                        var gundong = document.getElementById('gundong');
                        gundong.scrollTop = gundong.scrollTop - scroll_height;
                    })
                } else {
                    this.setState({ rowMedID: oneArr[0] ? (oneArr[0].medID || oneArr[0].ordSetID) : '' })
                }
                break;
            case 40: //下
                if (this.state.rowMedID) {
                    for (let i = 0; i < oneArr.length; i++) {
                        if ((oneArr[i].medID || oneArr[i].ordSetID) === this.state.rowMedID) {
                            id = i + 1 >= oneArr.length ? (oneArr[oneArr.length - 1].medID || oneArr[oneArr.length - 1].ordSetID)
                                : (oneArr[i + 1].medID || oneArr[i + 1].ordSetID);
                            break;
                        }
                    }
                    this.setState({ rowMedID: id }, () => {
                        var gundong = document.getElementById('gundong');
                        gundong.scrollTop = gundong.scrollTop + scroll_height;
                    })
                } else {
                    this.setState({ rowMedID: oneArr[0] ? (oneArr[0].medID || oneArr[0].ordSetID) : '' })
                }
                break;
        }
    }

    //点击左边列表的card进行显示隐藏
    hideLeftCard() {
        if (this.state.hideMessage === false) {
            this.setState({
                hideMessage: true
            })
        } else {
            this.setState({
                hideMessage: false
            })
        }
    }

    //点击按钮切换左边列表的显示数据
    handleSizeChange(e) {
        this.setState({ groupStatus: e.target.value })
    }

    onColumnRef = (ref) => {
        this.columnRef = ref;
    }
    onColumnFeeRef = (ref) => {
        this.feeRef = ref;
    }
    onColumnAdviceRef = (ref) => {
        this.adviceRef = ref;
    }
    onCollectRef = (ref) => {
        this.collectRef = ref;
    }
    onDetailRef = (ref) => {
        this.detailRef = ref;
    }

    onRef = (ref) => {
        this.child = ref;
    }

    //加载医嘱模板
    loadTemplate() {
        var templateTree = []
        this.state.templateData && this.state.templateData.map((item, index) => {
            templateTree.push(<TreeNode title={item.title} key={index + 'i' + '^'}>
                {this.loadSunTemplate(item.data)}
            </TreeNode>)
        })
        return templateTree
    }

    loadSunTemplate(data) {
        //depDoctorFlag 非本院医生不允许开医嘱
        var sunData = []
        data && data.map((item, index) => {
            // if(item.data) {
            sunData.push(<TreeNode title={item.title} nodeId={item.medID} ordSetID={item.ordSetID}
                disabled={this.state.titleData && this.state.titleData.depDoctorFlag == 'N' ? true :
                    ((item.stock == '0') ? true : false)} stock={item.stock}
                key={item.ordSetID + '-' + item.ordTempletDetailID + '^' + item.ordTempletDetailItemID || item.id || index}>
                {this.loadSunTemplate(item.data)}
            </TreeNode>)
            // }
        })
        return sunData
    }

    changeRadio(e) {
        this.setState({
            radioValue: e.target.value
        }, () => {
            this.loadTemplateData()
        })
    }

    onSearchTemplate(e) {
        if (e.keyCode == '13') {
            this.loadTemplateData()
        }
    }

    checkTreeNode() {

    }

    deleteNullData() {
        var that = this;
        var { dataSource, ids } = this.state;
        for (var j = 0; j < dataSource.length; j++) {
            if (Util.isEmpty(dataSource[j].ordMedItemID) && Util.isEmpty(dataSource[j].medID)) {
                that.state.dataSource.splice(j, 1);
            }
        }
        that.setState({})
    }


    loadTempTableData(status, record, data) {
        this.deleteNullData()
        var { dataSource } = this.state;
        // if (Util.isEmpty(data.props.nodeId) && Util.isEmpty(data.props.ordSetID)) {
        //     message.error(this.setMessage('DoctorAdviceListPageTemp', 'descripts'))
        //     return
        // }
        if (data.props.stock == '0') {
            return
        }
        this.state.dataSource.push({ tabIndex: this.state.dataSource.length + 1 });
        this.setState({
            groupStatus: false, indexTable: this.state.dataSource.length - 1,
            batchStatus: false
        }, () => {
            setTimeout(() => {
                if (Util.isEmpty(data.props.ordSetID)) {
                    this.loadTableData(status, record, data)
                } else {
                    this.loadCompleteData(status, record, data)
                }
            }, 100);
        })
    }

    loadCompleteData(status, record, data) {
        var that = this;
        var date = new Date();
        var { dataSource } = this.state;
        var source = []
        for (var i = 0; i < dataSource.length; i++) {
            if (Util.isEmpty(dataSource[i].ordID) && !Util.isEmpty(dataSource[i].medID)) {
                source.push(dataSource[i])
            }
        }
        var params = {
            params: [{
                admID: this.state.admID,
                indexID: source ? source.length : 0,
                orders: [{
                    medID: status == 'temp' ? data.props.nodeId : (status == 'batch' ? (record[0].ordSetID ? '' : record[0].medID) : record.medID),
                    ordSetID: status == 'temp' ? data.props.ordSetID : (status == 'batch' ? record[0].ordSetID : record.ordSetID || '')
                }]
            }]
        }
        $http.post('urlDeault', this, {
            code: '03050020',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    if (res.errorData.length == 1) {
                        message.error(res.errorData[0].errorMessage)
                        return
                    }

                    if (res.errorData.length > 0 || res.confirmData.length > 0) {
                        this.setState({
                            isShowConfirmModal: true,
                            errorData: res.errorData,
                            confirmData: res.confirmData,
                            adviceDrData: res.data,
                            newCode: []
                        })
                        return
                    } else if (Util.isEmpty(res.errorData) && Util.isEmpty(res.confirmData) && Util.isEmpty(res.data)) {
                        // message.error(this.setMessage('DoctorAdviceListPageNoData', 'descripts'))
                        return
                    }
                }
            }
        });
    }

    //鼠标移动添加样式
    addMouseOverStyle(name, e) {
        this.setState({
            addMouseStyle: true,
            indexStyle: name
        })
    }
    addMouseLeaveStyle() {
        this.setState({
            addMouseStyle: false,
            indexStyle: ''
        })
    }

    addMechansim() {
        var { dataSource } = this.state;
        //加入添加限制，只有录入了医嘱信息之后才能再次添加
        for (var i = 0; i < dataSource.length; i++) {
            if (Util.isEmpty(dataSource[i].medID) && Util.isEmpty(dataSource[i].ordMedItemDesc)) {
                message.error('	请先录入医嘱信息再添加！')
                return
            }
        }
        this.state.dataSource.push({ tabIndex: this.state.dataSource.length + 1 });
        this.setState({
            visible: true,
            changeValue: undefined,
            indexTable: this.state.dataSource.length - 1
        }, () => {
            this.ordMedItemDesc.current.focus()
            // this.selectFocus.current.props.onChange(this.state.dataSource.length-1)
        })
    }

    startChange(e) {
        this.setState({
            regDateFrom: e ? moment(e).format(dayFormat) : '',
        })
    }

    startChangeDate(e) {
        this.setState({
            dateFrom: e ? moment(e).format(dayFormat) : ''
        })
    }

    endChange(e) {
        this.setState({
            regDateTo: e ? moment(e).format(dayFormat) : ''
        })
    }

    endChangeDate(e) {
        this.setState({
            dateTo: e ? moment(e).format(dayFormat) : '',
        }, () => {
            this.loadExecList()
        })
    }

    changeInputMsg(name, e) {
        this.setState({
            [name]: e.target.value
        })
    }

    keyDownMsg(e) {
        if (e.keyCode == '13') {
            this.loadData(1)
        }
    }

    changeBedSelect(name, e) {
        this.setState({
            [name]: e
        }, () => {
            this.loadData(1)
        })
    }

    //点击行，渲染当前行样式 
    setRowClassName = (record) => {
        return record.admID === this.state.admID ? 'clickRowStyle' : '';
    }

    //点击行，渲染当前行样式
    onClickRow = (record) => {
        return {
            onClick: () => {
                if (this.state.admID == record.admID) {
                    this.setState({
                        admID: '',
                        record: '',
                        titleData: '',
                        collectionData: [],
                        detailData: [],
                        ordAdviceID: '',
                        ordExecID: '',
                        adviceIDs: [],
                        execIDs: [],
                        ordMedDescName: '',
                        dataSource: [{ indexTable: 0 }]
                    })
                } else {
                    this.state.patientIDs = [record.admID]
                    this.setState({
                        admID: record.admID,
                        record: record,
                        titleData: record,
                        collectionData: [],
                        detailData: [],
                        ordAdviceID: '',
                        ordExecID: '',
                        adviceIDs: [],
                        execIDs: [],
                        ordMedDescName: '',
                        dataSource: [{ indexTable: 0 }]
                    }, () => {
                        this.loadAdviceList(1)
                        this.loadAdviceSelectData()
                        this.handleAccountBtn()
                    })
                }
            }
        };
    }

    hideModal(name) {
        this.setState({
            [name]: false
        })
    }

    //取消弹框显示，焦点问题
    handleFocus() {
        this.setState({
            selectData: []
        }, () => {
            if (!this.state.focusStatus) {
                this.ordMedItemDesc.current.focus()
            }
        })
    }

    onSelectChange(ids, selectID) {
        this.setState({
            ids: ids,
            selectID: selectID
        })
    }

    changeAdviceList(adviceIDs, rows) {
        var ordStatus = []
        rows.map((value) => {
            if (value.objStatus === 'Y' && value.ordHandleStatus === '已处理') {
                // var obj={};
                // obj.ordName=value.ordDesc;
                // obj.status=value.objStatus;
                var strMessage = value.ordDesc + '已经领过药了，需退还药品才不计费!';
                ordStatus.push(strMessage);
            }

        })
        this.setState({
            adviceIDs,
            ordStatus
        })
    }

    onChangeExecList(execIDs) {
        this.setState({
            execIDs
        })
    }

    delMechansim() {
        // this.loadDeleteTemplate()
        var flag = true;
        var that = this;
        var { dataSource, ids } = this.state;
        var test = []
        if (ids.length < 1) {
            message.error('请选择您需要删除的数据！')
            return
        }
        for (var i = 0; i < dataSource.length; i++) {
            if (!Util.isEmpty(dataSource[i].ordID)) {
                test.push(dataSource[i])
            }
        }

        confirm({
            title: '删除',
            content: '你确定要删除当前选中的数据吗？',
            okText: that.state.userData.language == 'EN' ? 'Ok' : '确定',
            cancelText: that.state.userData.language == 'EN' ? 'cancel' : '取消',
            onOk() {
                for (var i = 0; i < ids.length; i++) {
                    for (var j = 0; j < dataSource.length; j++) {
                        if (dataSource[j].tabIndex && ids[i] == dataSource[j].tabIndex) {
                            that.state.dataSource.splice(j, 1);
                        }
                    }
                }
                that.setState({ ids: [], changeValue: '' })
            },
            onCancel() {
                console.log('Cancel');
            },
        });
    }

    //插入医嘱
    insertDoctorAdvice = Util.debounce(() => {
        var { dataSource, ids } = this.state;
        this.setState({ btnStatus: true });
        var temp = []
        //将默认数据过滤掉，只传新添加的数据
        for (var i = 0; i < dataSource.length; i++) {
            if (!Util.isEmpty(dataSource[i].medID)) {
                temp.push(dataSource[i])
            }
        }

        //过滤多余的数据
        var tempData = []
        for (var i = 0; i < temp.length; i++) {
            tempData.push({
                ...temp[i],
                qtyUnitList: undefined,
                bodyPartList: undefined,
                specList: undefined,
                ordbodyPart: temp[i].ordbodyPartID,
            })
        }

        var params = {
            params: [
                {
                    admStr: [this.state.admID],
                    locID: this.state.userData.locID,
                    docID: this.state.userData.userID,
                    userID: this.state.userData.userID,
                    hospID: this.state.userData.hospID,
                    orders: tempData,
                }
            ]
        }
        $http.post('urlDeault', this, {
            code: '03060021',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        dataSource: [{ indexTable: 0 }],
                        btnStatus: false
                    }, () => {
                        this.loadAdviceList(1)
                    })
                    message.success('保存医嘱成功')
                } else {
                    this.setState({ btnStatus: false })
                }
            },
            error: function () {
                this.setState({ btnStatus: false })
            }
        });
    })
    //账单按钮
    handleAccountBtn() {
        var params = {
            params: [{
                userID: this.state.userData.userID,
                admID: this.state.admID,
            }]
        }
        $http.post('urlDeault', this, {
            code: '03060029',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    message.success('账单成功！')
                    this.handleResetList()//刷新title
                }
            }
        });
    }

    handleResetList() {
        var params = {
            params: [{
                locID: this.state.userData.locID,
                userID: this.state.userData.userID,
                hospID: this.state.userData.hospID,
                admStatusCode: this.state.admStatusCode,
                wardID: this.state.wardID,
                medGroupID: this.state.medGroupID,
                levelCode: this.state.levelCode,
                conditionCode: this.state.conditionCode,
                patMessage: this.state.patMessage,
                bedID: this.state.bedID,
                medicalNo: this.state.medicalNo,
                nurseGroupID: this.state.nurseGroupID,
                dateFrom: this.state.admStatusCode == 'D' ? this.state.dateFrom : '',
                dateTo: this.state.admStatusCode == 'D' ? this.state.dateTo : ''
            }],
            // pagination: [{
            //     pageSize: this.state.leftSize,
            //     currentPage: page
            // }]
        }
        $http.post('urlDeault', this, {
            code: '03060004',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    var source = res.result.data
                    var titleData = ''
                    if (!Util.isEmpty(source)) {
                        for (var i = 0; i < source.length; i++) {
                            if (source[i].admID == this.state.admID) {
                                titleData = source[i]
                            }
                        }
                    }
                    this.setState({
                        leftData: res.result.data,
                        titleData: titleData,
                        admStatusData: res.result.admStatusData,
                        wardData: res.result.wardData,
                        medGroupData: res.result.medGroupData,
                        levelData: res.result.levelData,
                        conditionData: res.result.conditionData,
                        total: res.result.totalCount
                    })
                }
            }
        });
    }

    batchSaveAdviceList(admID, source) {
        var temp = []
        //将默认数据过滤掉，只传新添加的数据
        for (var i = 0; i < source.length; i++) {
            if (!Util.isEmpty(source[i].medID)) {
                temp.push(source[i])
            }
        }

        //过滤多余的数据
        var tempData = []
        for (var i = 0; i < temp.length; i++) {
            tempData.push({
                ...temp[i],
                qtyUnitList: undefined,
            })
        }

        var params = {
            params: [
                {
                    admStr: admID,
                    locID: this.state.userData.locID,
                    docID: this.state.userData.userID,
                    userID: this.state.userData.userID,
                    hospID: this.state.userData.hospID,
                    orders: tempData,
                }
            ]
        }
        $http.post('urlDeault', this, {
            code: '03060021',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    message.success('保存医嘱成功')
                    this.hideModal('isShowCollectionCostModal')
                    this.setState({
                        patientIDs: []
                    }, () => {
                        this.loadAdviceList(1)
                    })
                }
            }
        });
    }

    handleExecList(name) {
        if (name == 'F') {
            this.setState({
                isShowExecListModal: true
            })
        } else {
            this.handleDealExecList(name)
        }
    }

    handleSaveDealExecList(name, dateFrom, timeFrom) {
        this.handleDealExecList(name, dateFrom, timeFrom)
    }

    //执行、撤销、停止执行
    handleDealExecList(name, dateFrom, timeFrom) {
        var params = {}
        if (name == 'F') {
            params = {
                params: [{
                    ordIDs: this.state.execIDs,
                    locID: this.state.userData.locID,
                    userID: this.state.userData.userID,
                    date: dateFrom,
                    time: timeFrom,
                    code: name,
                }]
            }
        } else {
            params = {
                params: [
                    {
                        ordIDs: this.state.execIDs,
                        locID: this.state.userData.locID,
                        userID: this.state.userData.userID,
                        code: name,
                    }
                ]
            }
        }
        $http.post('urlDeault', this, {
            code: '04030003',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    if (!Util.isEmpty(res.errorArr)) {
                        message.error((res.errorArr).join(','))
                    } else {
                        message.success('操作成功！')
                    }
                    this.loadAdviceCollectionList(1)
                    this.hideModal('isShowExecListModal')
                    this.setState({
                        execIDs: []
                    })
                }
            }
        });
    }

    keyDownInput(e) {
        var searchCode = this.state.searchCode;
        searchCode = searchCode.replace(/ /g, '')
        if (e.keyCode == '13') {
            if (!Util.isEmpty(this.state.searchCode) && !Util.isEmpty(searchCode)) {
                this.loadAdviceList(1)
            }
        }
    }

    commonSelectOption(name, e) {
        this.setState({
            [name]: e,
        })
        /**
         * , () => {
            this.loadAdviceList(1)
        }
         */
    }

    //处理医嘱清单操作
    handleDetailMsg() {
        if (Util.isEmpty(this.state.adviceIDs)) {
            message.error('请选择需要处理的医嘱！')
            return
        }
        this.setState({
            isShowDealWithAdvice: true
        })
    }

    onSubmitDealAdvice(type, dateFrom, timeFrom) {
        var params = {}
        if (type == 'cannel') {
            if (Util.isEmpty(this.state.adviceIDs)) {
                message.error('请选择需要撤销处理的医嘱！')
                return
            }
            var strName = '';
            this.state.ordStatus.map(value => {
                strName += value + '  ';
            })
            if (strName.trim() !== '') {
                message.info('无法撤销处理！' + strName);
                return
            }
            params = {
                params: [{
                    userID: this.state.userData.userID,
                    locID: this.state.userData.locID,
                    ordIDs: this.state.adviceIDs,
                    type: ''
                }]
            }
        } else {
            params = {
                params: [{
                    userID: this.state.userData.userID,
                    locID: this.state.userData.locID,
                    ordIDs: this.state.adviceIDs,
                    date: dateFrom,
                    time: timeFrom,
                    type: type,
                }]
            }
        }
        $http.post('urlDeault', this, {
            code: '04030002',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    message.success('操作成功！')
                    this.setState({
                        adviceIDs: []
                    }, () => {
                        this.hideModal('isShowDealWithAdvice')
                        this.loadAdviceList(1)
                    })
                }
            }
        });
    }

    //撤销
    handleUndoAdvice() {
        var { adviceIDs } = this.state;
        if (Util.isEmpty(adviceIDs)) {
            message.error('请选择您需要撤销的医嘱！')
            return
        }
        var params = {
            params: [{
                ordID: this.state.adviceIDs,
                userID: this.state.userData.userID,
                locID: this.state.userData.locID,
            }]
        }
        $http.post('urlDeault', this, {
            code: '03060010',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    message.success('操作成功！')
                    this.loadAdviceList(1)
                    this.setState({
                        adviceIDs: []
                    })
                }
            }
        });
    }

    onChangePatientIDs(patientIDs, patientMsg) {
        this.setState({
            patientIDs: patientIDs,
            patientMsg: patientMsg,
        })
    }

    //批量补录
    batchCollectionCost() {
        var { patientIDs } = this.state;
        if (Util.isEmpty(patientIDs)) {
            message.error('请选择需要补录的病人！')
            return
        }
        this.setState({
            isShowCollectionCostModal: true,
        })
    }

    //多选模板，确认错误弹框
    confirmAdviceModal(data) {
        var that = this;
        var date = new Date();
        var validData = [], textData = [];
        var { adviceDrData, dataSource, nodeId, confirmData } = this.state;
        this.deleteNullData()

        var result = [];
        //取两个数组的不同数据
        for (var i = 0; i < adviceDrData.length; i++) {
            var obj = adviceDrData[i];
            var num = obj.indexId;
            var isExist = false;
            for (var j = 0; j < confirmData.length; j++) {
                var aj = confirmData[j];
                var n = aj.indexId;
                if (n == num) {
                    isExist = true;
                    break;
                }
            }
            if (!isExist) {
                result.push(obj);
            }
        }
        var userCode = []
        for (var i = 0; i < adviceDrData.length; i++) {
            var obj = adviceDrData[i];
            var num = obj.indexId;
            var isExist = false;
            for (var j = 0; j < data.length; j++) {
                var aj = data[j];
                var n = aj.indexId;
                if (n == num) {
                    textData.push(obj)
                    isExist = true;
                    break;
                }
            }
            if (!isExist) {
                userCode.push(obj);
            }
        }
        validData = result.concat(textData)
        for (var i = 0; i < validData.length; i++) {
            this.state.dataSource.push({ tabIndex: this.state.dataSource.length + 1 })
            this.state.indexArray.push({ index: this.state.dataSource.length - 1, indexId: validData[i].indexId })
            this.setState({ groupStatus: false })
        }
        //冒泡排序，用来处理关联排序问题
        for (var i = 0; i < validData.length - 1; i++) {
            for (var j = 0; j < validData.length - i - 1; j++) {
                if (validData[j].indexId > validData[j + 1].indexId) {
                    var temp = validData[j].indexId
                    validData[j].indexId = validData[j + 1].indexId
                    validData[j + 1].indexId = temp
                }
            }
        }
        var { indexArray } = this.state;
        for (var i = 0; i < validData.length; i++) {
            for (var j = 0; j < indexArray.length; j++) {
                //indexArray[j].index && indexArray[j].indexId == validData[i].indexId
                if (indexArray[j].indexId == validData[i].indexId) {
                    that.state.dataSource[indexArray[j].index]['indexId'] = validData[i].indexId
                    if (indexArray[j - 1] && indexArray[j - 1].indexId == validData[i].mainIndexId) {
                        that.state.dataSource[indexArray[j - 1].index]['identity'] = ''
                    }
                    if (j > 0 && !Util.isEmpty(validData[i].mainIndexId)) {
                        that.state.dataSource[indexArray[i].index]['identity'] = '1'
                    }
                    validData[i]['newCode'] = i,
                        that.state.dataSource[indexArray[j].index]['mainIndexId'] = validData[i].mainIndexId,
                        // that.state.dataSource[indexArray[j].index]['ordLinkSeqNo'] = validData[i].mainIndexId,
                        that.state.dataSource[indexArray[j].index]['ordMedItemDesc'] = validData[i].defaultData.ordDesc,
                        that.state.dataSource[indexArray[j].index]['ordDose'] = validData[i].defaultData.ordDose,
                        that.state.dataSource[indexArray[j].index]['ordDoseUnitID'] = validData[i].defaultData.ordDoseUnitID,
                        // that.state.dataSource[indexArray[j].index]['ordFreqID'] = validData[i].defaultData.ordFrequenceID,
                        that.state.dataSource[indexArray[j].index]['ordFreqID'] = validData[i].defaultData.ordFreqID,
                        that.state.dataSource[indexArray[j].index]['ordFreqDesc'] = validData[i].defaultData.ordFreqDesc,
                        that.state.dataSource[indexArray[j].index]['ordUsageID'] = validData[i].defaultData.ordUsageID,
                        that.state.dataSource[indexArray[j].index]['ordDurQty'] = validData[i].defaultData.ordDurQty,
                        that.state.dataSource[indexArray[j].index]['ordDurationID'] = validData[i].defaultData.ordDurationID,
                        that.state.dataSource[indexArray[j].index]['ordQty'] = validData[i].defaultData.ordQty,
                        that.state.dataSource[indexArray[j].index]['ordQtyUomID'] = validData[i].defaultData.ordQtyUomID,
                        that.state.dataSource[indexArray[j].index]['ordbodyPartID'] = validData[i].defaultData.ordbodyPartID,
                        that.state.dataSource[indexArray[j].index]['ordPrice'] = validData[i].defaultData.ordPrice,
                        that.state.dataSource[indexArray[j].index]['ordSkinTestFlag'] = validData[i].defaultData.ordSkinTestFlag,
                        that.state.dataSource[indexArray[j].index]['testFlag'] = validData[i].defaultData.ordSkinTestFlag,
                        that.state.dataSource[indexArray[j].index]['ordSkinTestWayID'] = validData[i].defaultData.ordSkinTestWayID,
                        that.state.dataSource[indexArray[j].index]['ordRecLocID'] = validData[i].defaultData.ordRecLocID,
                        that.state.dataSource[indexArray[j].index]['ordSkinTestUsageDesc'] = validData[i].defaultData.ordSkinTestUsageDesc,
                        that.state.dataSource[indexArray[j].index]['ordSkinTestUsageID'] = validData[i].defaultData.ordSkinTestUsageID,

                        that.state.dataSource[indexArray[j].index]['ordUsageDesc'] = validData[i].defaultData.ordUsageDesc,
                        that.state.dataSource[indexArray[j].index]['ordUsageID'] = validData[i].defaultData.ordUsageID,

                        that.state.dataSource[indexArray[j].index]['ordPriorityID'] = validData[i].defaultData.ordPriorityID,
                        that.state.dataSource[indexArray[j].index]['medDesca'] = validData[i].defaultData.ordDesca,
                        that.state.dataSource[indexArray[j].index]['ordAdmReasonID'] = validData[i].defaultData.ordAdmReasonID,
                        that.state.dataSource[indexArray[j].index]['ordSeqNo'] = parseInt(indexArray[j].index) + 1,

                        that.state.dataSource[indexArray[j].index]['ordDate'] = validData[i]?.defaultData?.ordDate || validData[i]?.defaultData?.date || moment(date).format(dayFormat),
                        that.state.dataSource[indexArray[j].index]['ordTime'] = validData[i]?.defaultData?.ordTime || validData[i]?.defaultData?.time || moment(date).format(timeFormat),

                        that.state.dataSource[indexArray[j].index]['ordStartDate'] = validData[i]?.defaultData?.ordStartDate || validData[i]?.defaultData?.date || moment(date).format(dayFormat),
                        that.state.dataSource[indexArray[j].index]['ordStartTime'] = validData[i]?.defaultData?.ordStartTime || validData[i]?.defaultData?.time || moment(date).format(timeFormat),
                        that.state.dataSource[indexArray[j].index]['ordNote'] = validData[i].defaultData.ordNote,
                        that.state.dataSource[indexArray[j].index]['medID'] = validData[i].defaultData.medID,
                        that.state.dataSource[indexArray[j].index]['ordTypeCode'] = validData[i].defaultData.ordTypeCode,
                        that.state.dataSource[indexArray[j].index]['ordSpecID'] = validData[i].defaultData.ordSpecID,
                        that.state.dataSource[indexArray[j].index]['ordSkinTestFlag'] = validData[i].defaultData.ordSkinTestFlag,
                        that.state.dataSource[indexArray[j].index]['testFlag'] = validData[i].defaultData.ordSkinTestFlag,
                        that.state.dataSource[indexArray[j].index]['ordEMFlag'] = validData[i].defaultData.ordEMFlag,
                        that.state.dataSource[indexArray[j].index]['testEMFlag'] = validData[i].defaultData.ordEMFlag,
                        that.state.dataSource[indexArray[j].index]['ordToalCountO'] = validData[i].defaultData.ordToalCountO,
                        that.state.dataSource[indexArray[j].index]['ordToalCountI'] = validData[i].defaultData.ordToalCountI,
                        that.state.dataSource[indexArray[j].index]['frequency'] = validData[i].defaultData.frequency,
                        that.state.dataSource[indexArray[j].index]['cycleDays'] = validData[i].defaultData.cycleDays,
                        that.state.dataSource[indexArray[j].index]['ordStageID'] = validData[i].defaultData.ordStageID,
                        that.state.dataSource[indexArray[j].index]['intervalDays'] = validData[i].defaultData.intervalDays,
                        that.state.dataSource[indexArray[j].index]['duraFactor'] = validData[i].defaultData.duraFactor,
                        that.state.dataSource[indexArray[j].index]['doseDenominator'] = validData[i].defaultData.doseDenominator,
                        that.state.dataSource[indexArray[j].index]['doseMolecule'] = validData[i].defaultData.doseMolecule,
                        that.state.dataSource[indexArray[j].index]['qtyMolecule'] = validData[i].defaultData.qtyMolecule,
                        that.state.dataSource[indexArray[j].index]['qtyDenominator'] = validData[i].defaultData.qtyDenominator,
                        that.state.dataSource[indexArray[j].index]['ordPriorityExtID'] = validData[i].defaultData.ordPriorityExtID,
                        that.state.dataSource[indexArray[j].index]['ordMessage'] = validData[i].defaultData.ordMessage,
                        that.state.dataSource[indexArray[j].index]['ordMedItemID'] = validData[i].defaultData.medID,
                        that.state.dataSource[indexArray[j].index]['ordEMFlagValue'] = validData[i].defaultData.ordEMFlagValue,
                        that.state.dataSource[indexArray[j].index]['ordSkinTestFlagValue'] = validData[i].defaultData.ordSkinTestFlagValue,
                        that.state.dataSource[indexArray[j].index]['ordPriorityExtDesc'] = validData[i].defaultData.ordPriorityExtDesc,
                        // that.state.dataSource[indexArray[j].index]['usageList'] = validData[i].dataList.usageList,
                        that.state.dataSource[indexArray[j].index]['doseUnitList'] = validData[i].dataList.doseUnitList,
                        that.state.dataSource[indexArray[j].index]['durationList'] = validData[i].dataList.durationList,
                        that.state.dataSource[indexArray[j].index]['stageList'] = validData[i].dataList.stageList,
                        that.state.dataSource[indexArray[j].index]['qtyUnitList'] = validData[i].dataList.qtyUnitList,
                        that.state.dataSource[indexArray[j].index]['recLocList'] = validData[i].dataList.recLocList,
                        // that.state.dataSource[indexArray[j].index]['frequenceList'] = validData[i].dataList.frequenceList,
                        that.state.dataSource[indexArray[j].index]['skinTestWayList'] = validData[i].dataList.skinTestWayList,
                        that.state.dataSource[indexArray[j].index]['priorityList'] = validData[i].dataList.priorityList,
                        that.state.dataSource[indexArray[j].index]['admReasonList'] = validData[i].dataList.admReasonList,
                        that.state.dataSource[indexArray[j].index]['specList'] = validData[i].dataList.specList,
                        that.state.dataSource[indexArray[j].index]['causeList'] = validData[i].dataList.causeList,
                        that.state.dataSource[indexArray[j].index]['priorityExtList'] = validData[i].dataList.priorityExtList ? validData[i].dataList.priorityExtList : [],
                        that.state.qtyUnitList[indexArray[j].index] = validData[i].dataList.qtyUnitList,
                        that.state.specList[indexArray[j].index] = validData[i].dataList.specList,
                        that.state.bodyPartList[indexArray[j].index] = validData[i].dataList.bodyPartList,
                        this.setState({
                            tableData: validData[i].defaultData, batchStatus: true, copyData: validData,
                            indexArray: [], newCode: []
                        })
                }
            }
        }
        this.hideModal('isShowConfirmModal')
    }

    render() {
        var { bedData, top, left, selectData, page, total, ids, adviceIDs, execIDs, ordLocList,
            ordStatusList, priorityList, handlerStatusList, patientIDs, nurseGroup, btnStatus } = this.state;

        //医嘱录入
        const rowSelection = {
            ids,
            onChange: this.onSelectChange.bind(this),
            selectedRowKeys: ids,
        }

        //医嘱清单
        const rowSelectionList = {
            adviceIDs,
            onChange: this.changeAdviceList.bind(this),
            selectedRowKeys: adviceIDs,
        }

        //执行记录
        const execRowSelection = {
            execIDs,
            onChange: this.onChangeExecList.bind(this),
            selectedRowKeys: execIDs,
            getCheckboxProps: record => ({
                disabled: this.state.subOrderFlag == 'Y', // Column configuration not to be checked
            }),
        }

        //病人列表
        const patientListSelection = {
            patientIDs,
            onChange: this.onChangePatientIDs.bind(this),
            selectedRowKeys: patientIDs
        }

        var moduleDataOption = []
        if (this.state.moduleData) {
            this.state.moduleData && this.state.moduleData.map((item, index) => {
                moduleDataOption.push(
                    <Radio value={item.id} key={item.id}>{item.descripts}</Radio>
                )
            })
        }

        var bedDataOption = []
        bedData && bedData.map((item, index) => {
            bedDataOption.push(<Option key={index} value={item.bedID} title={item.bedNo}><Tooltip title={item.bedNo}>{item.bedNo}</Tooltip></Option>)
        })

        //开单科室
        var ordLocListOption = []
        ordLocList && ordLocList.map((item, index) => {
            ordLocListOption.push(<Option key={index} value={item.id}>{item.descripts}</Option>)
        })

        //医嘱状态
        var ordStatusListOption = []
        ordStatusList && ordStatusList.map((item, index) => {
            ordStatusListOption.push(<Option key={index} code={item.code} value={item.id}>{item.descripts}</Option>)
        })

        //护理分组
        var nurseGroupOption = []
        nurseGroup && nurseGroup.map((item, index) => {
            nurseGroupOption.push(<Option key={index} code={item.descriptsSPCode} value={item.id}>{item.descripts}</Option>)
        })
        //医嘱类型
        var priorityListOption = []
        priorityList && priorityList.map((item, index) => {
            priorityListOption.push(<Option key={index} code={item.descriptsSPCode} value={item.id}>{item.descripts}</Option>)
        })
        //处理状态
        var handlerStatusListOption = []
        handlerStatusList && handlerStatusList.map((item, index) => {
            handlerStatusListOption.push(<Option key={index} value={item.code}>{item.descripts}</Option>)
        })


        let param = {
            width: '96vh',
            // height: 300,
            top: top,
            left: left,
            columns: this.sunColumns,
            data: selectData,
            isOnRow: true,
            TableClassName: 'tab-placeholder',
            rowClassName: true,
            showPagination: true,
            page,
            total,
        }

        return <div className="collection-cost-body" style={{ background: '#f1f2f5', height: '100%', width: '100%' }}>
            <div className="doctor-advice-common-modal"
                tabIndex={1}
                onKeyDown={this.handleOnKeydown.bind(this)}
                style={{ outline: 'none' }}
            >
                <ShowCommonTableModal onClickRowPublic={this.onClickRowPublic}
                    setRowClassNamePublic={this.setRowClassNamePublic}
                    isShow={this.state.isShowCommonTableModal}
                    handleFocus={this.handleFocus.bind(this)}
                    onHide={this.hideModal.bind(this, 'isShowCommonTableModal')}
                    param={param}
                    onRef={this.onRef}
                    search={this.state.search}
                    id="gundong"
                    compilePage={this.changePageSize.bind(this)}>
                </ShowCommonTableModal></div>
            <ColumnAuthoritysModel
                clientWidth="800px"
                compontName="CollectionList"
                configType="C"
                onRef={this.onColumnRef}
                reloadData={this.loadCollectionListColumns}
            />
            <ColumnAuthoritysModel
                clientWidth="800px"
                compontName="addAdviceListPage"
                configType="C"
                onRef={this.onColumnFeeRef}
                reloadData={this.initData}
            />
            <ColumnAuthoritysModel
                clientWidth="800px"
                compontName="adviceListPage"
                configType="C"
                onRef={this.onColumnAdviceRef}
                reloadData={this.loadAdviceColumns}
            />
            <ColumnAuthoritysModel
                clientWidth="800px"
                compontName="executionList"
                configType="C"
                onRef={this.onCollectRef}
                reloadData={this.loadExecutListColumns}
            />
            <ColumnAuthoritysModel
                clientWidth="800px"
                compontName="chargeDetails"
                configType="C"
                onRef={this.onDetailRef}
                reloadData={this.loadChargeDetails}
            />
            {/**处理医嘱 */}
            <ShowDealWithAdvice isShow={this.state.isShowDealWithAdvice}
                onSubmit={this.onSubmitDealAdvice.bind(this)}
                onHide={this.hideModal.bind(this, 'isShowDealWithAdvice')}>
            </ShowDealWithAdvice>
            {/**执行记录 */}
            <ShowExecListModal isShow={this.state.isShowExecListModal}
                onHide={this.hideModal.bind(this, 'isShowExecListModal')}
                onSubmit={this.handleSaveDealExecList.bind(this)}>
            </ShowExecListModal>
            {/**批量补录医嘱 */}
            <ShowCollectionCostModal isShow={this.state.isShowCollectionCostModal}
                patientMsg={this.state.patientMsg}
                patientIDs={this.state.patientIDs}
                onSubmit={this.batchSaveAdviceList.bind(this)}
                onHide={this.hideModal.bind(this, 'isShowCollectionCostModal')}>
            </ShowCollectionCostModal>

            {/**确认医嘱弹框 */}
            <ShowConfirmModal isShow={this.state.isShowConfirmModal}
                confirmData={this.state.confirmData}
                errorData={this.state.errorData}
                onSubmit={this.confirmAdviceModal.bind(this)}
                onHide={this.hideModal.bind(this, 'isShowConfirmModal')}>
            </ShowConfirmModal>

            {this.state.hideMessage === false ? <Card style={{ height: '92vh', width: '20%', float: 'left' }}
                title={<RadioGroup value={this.state.groupStatus} onChange={this.handleSizeChange.bind(this)}>
                    <RadioButton key='1' value='1'>病人列表</RadioButton>
                    <RadioButton key='2' value='2'>模板</RadioButton>
                </RadioGroup>}
                extra={<div onClick={this.hideLeftCard.bind(this)}>
                    <Tooltip title='隐藏病人列表'><Icon type="double-left" style={{ fontSize: '20px', cursor: 'pointer' }} /></Tooltip></div>}>
                {this.state.groupStatus == '1' ? <div>
                    <Row style={{ textAlign: 'right' }}>
                        <Col>
                            人员标识：<Input placeholder='病人ID/姓名/身份证号码/手机号码' style={{ width: '76%' }}
                                onChange={this.changeInputMsg.bind(this, 'patMessage')}
                                onKeyDown={this.keyDownMsg.bind(this)} />
                        </Col>
                        <Col style={{ marginTop: 5 }}>
                            住院号：<Input placeholder='请输入住院号' style={{ width: '30%' }}
                                onChange={this.changeInputMsg.bind(this, 'medicalNo')}
                                onKeyDown={this.keyDownMsg.bind(this)} />&nbsp;&nbsp;
                            床号：<Select placeholder='请选择床号' style={{ width: '30%' }} allowClear showSearch
                                dropdownMatchSelectWidth={false}
                                filterOption={(input, option) => option.props.title.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                onChange={this.changeBedSelect.bind(this, 'bedID')}>
                                {bedDataOption}</Select>
                        </Col>
                        <Col style={{ marginTop: 5 }}>
                            护理分组：<Select placeholder='请选择所属分组' style={{ width: '30%', marginRight: 13 }}
                                onChange={Util.handleSelectChange.bind(this, 'nurseGroupID')} allowClear showSearch
                                filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
                                    option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0}>
                                {nurseGroupOption}
                            </Select>
                            快捷：<Select placeholder='请选择快捷' style={{ width: '30%' }}></Select>
                        </Col>
                        <Col style={{ marginTop: 5 }}>
                            <Button style={{ background: '#13C2C2', color: 'white' }}
                                onClick={this.batchCollectionCost.bind(this)}>批量补录</Button>
                            <Button style={{ marginLeft: 5 }} type='primary' onClick={this.loadData.bind(this, '1')}>查询</Button>
                        </Col>
                    </Row>
                    <Row style={{ marginTop: 5 }}>
                        <Table columns={this.state.leftColumns} dataSource={this.state.leftData}
                            className='collection-left-table'
                            onHeaderRow={column => {
                                return {
                                    onDoubleClick: () => {
                                        this.columnRef.onOpenModel();
                                    },
                                };
                            }}
                            rowKey={(data) => {
                                return data.admID
                            }}
                            onRow={this.onClickRow} bordered
                            rowClassName={this.setRowClassName}
                            rowSelection={patientListSelection}
                            scroll={{ x: this.state.leftWidth, y: store.getState().tableHeight.y - 20 }}
                            pagination={false}></Table>
                    </Row>
                </div> :
                    <div>
                        <Input style={{ width: '90%', marginLeft: '5%' }}
                            prefix={<Icon type="search" style={{ color: 'rgba(0,0,0,.25)' }} />}
                            placeholder={'输入模板/医嘱项名称/别名回车查询'} onChange={Util.commonInputChange.bind(this, 'templateInput')}
                            onKeyDown={this.onSearchTemplate.bind(this)} />
                        <div className='doctor-left-radio'>
                            <Radio.Group value={this.state.radioValue}
                                onChange={this.changeRadio.bind(this)}>
                                {moduleDataOption}
                            </Radio.Group>
                        </div>
                        <Tree defaultExpandAll={true} defaultExpandedKeys={['1']} style={{ height: '79vh', overflow: 'auto' }}
                            checkedKeys={this.state.newCode}
                            onCheck={this.checkTreeNode.bind(this)}
                            onDoubleClick={this.loadTempTableData.bind(this, 'temp')}>
                            {this.loadTemplate()}
                        </Tree>
                    </div>
                }
            </Card> :
                <Card style={{ height: '92vh', width: '2.3%', float: 'left', cursor: 'pointer' }}
                    className='collection-hide-modal' onClick={this.hideLeftCard.bind(this)}
                    title={<Tooltip title='展开病人列表'><Icon type="double-right" style={{ fontSize: '20px', cursor: 'pointer' }}
                        onClick={this.hideLeftCard.bind(this)} /></Tooltip>}><span >展开病人列表</span></Card>
            }

            <Card style={{ height: '92vh', width: (this.state.hideMessage === false ? '79.8%' : '97.5%'), float: 'right' }}
                bodyStyle={{ padding: '0px 2px' }}>
                <Row style={{ height: 80 }} >
                    <div style={{ width: '36%', borderRight: '1px solid #EEEEEE', height: 79, display: 'flex', float: 'left' }}>
                        <div className={this.state.titleData && this.state.titleData.patSexCode == '1' ?
                            'splice-boy' : (this.state.titleData && this.state.titleData.patSexCode == '2' ? 'splice-girl' : 'splice-other')}></div>
                        <div style={{ height: 79, borderRight: '1px solid #EEEEEE' }}></div>
                        {!Util.isEmpty(this.state.titleData) ? <div style={{ fontSize: '16px' }}>
                            <div style={{ padding: '10px 0 0 10px' }}>
                                <span style={{ fontSize: '20px', color: '#1999db', fontWeight: 'blod' }}>
                                    {this.state.titleData ? this.state.titleData.bedNo || '--' : '--'}</span><Divider type="vertical" />
                                <span style={{ color: '#333333', fontWeight: 'bold' }}>{this.state.titleData ? this.state.titleData.patName || '--' : '--'}</span><Divider type="vertical" />
                                <span>{this.state.titleData ? this.state.titleData.patSexDesc || '--' : '--'}</span><Divider type="vertical" />
                                <span>{this.state.titleData ? this.state.titleData.patAge || '--' : '--'}</span><Divider type="vertical" />
                                <span><Icon className='patNo-splice' />{this.state.titleData ? this.state.titleData.patNo || '--' : '--'}</span>
                            </div>
                            <div style={{ fontWeight: 400, color: '#666666', fontSize: '16px', padding: '10px 0 0 10px' }}>
                                <span><Icon className='statusdesc-splice' />{this.state.titleData ? this.state.titleData.patSocialStatusDesc || '--' : '--'}</span><Divider type="vertical" />
                                <span><Icon className='typeDesc-splice' />{this.state.titleData ? this.state.titleData.patTypeDesc || '--' : '--'}</span><Divider type="vertical" />
                                <span>
                                    <span style={{ color: '#1999db' }}><Icon className='account-splice' />{this.state.titleData ? this.state.titleData.accountBalance || '--' : 0}</span> </span>
                            </div>
                        </div> : <span style={{ color: '#999999', lineHeight: '79px', marginLeft: '20%' }}>{'暂无相关数据～'}</span>}
                    </div>
                    <div style={{ padding: '5px', width: '63.5%', float: 'right' }}>
                        {/* 费用展示区域 */}
                    </div>
                </Row>

                <Row style={{ borderTop: '1px solid #EEEEEE' }}>
                    <Col>
                        <div style={{ height: 30, lineHeight: '30px' }}>
                            <div style={{ float: 'left' }}>
                                <span style={{ cursor: 'pointer' }} className={this.state.indexStyle == '1' ? 'mouse-add-Style' : ''}
                                    onClick={this.addMechansim.bind(this)}
                                    onMouseLeave={this.addMouseLeaveStyle.bind(this)}
                                    onMouseOver={this.addMouseOverStyle.bind(this, '1')}
                                >
                                    <Icon className='doctor-add-splice' style={{ marginTop: 3 }} />
                                    <span>添加</span>
                                </span><Divider type="vertical" />
                                <span style={{ cursor: 'pointer' }} className={this.state.indexStyle == '2' ? 'mouse-add-Style' : ''}
                                    onClick={this.delMechansim.bind(this)}
                                    onMouseLeave={this.addMouseLeaveStyle.bind(this)}
                                    onMouseOver={this.addMouseOverStyle.bind(this, '2')}>
                                    <Icon className='doctor-delete-splice' style={{ marginTop: 3 }} />
                                    <span>删除</span>
                                </span><Divider type="vertical" />
                                <Button type='primary' size='small' onClick={this.insertDoctorAdvice} disabled={btnStatus}>保存</Button><Divider type="vertical" />
                                <Button type='primary' size='small' disabled={Util.isEmpty(this.state.admID)} onClick={this.handleAccountBtn.bind(this)}>账单</Button>
                            </div>

                            <div style={{ float: 'right', marginRight: 10 }}>
                                <span>
                                    <span style={{ color: 'rgb(153, 153, 153)' }}>当前已选择医嘱：</span>
                                    <span>{this.state.ordMedDescName || '无'}</span>
                                </span><Divider type="vertical" />

                                {/* <span>
                                    <span style={{ color: '#1999db' }}>补录类型：</span>
                                    <Select placeholder='请选择补录类型' style={{ width: '15vh' }}></Select>
                                </span> */}
                            </div>
                        </div>
                        <Table columns={this.state.feeColumns} dataSource={this.state.dataSource}
                            style={{ height: '15vh' }}
                            scroll={{ y: '10vh' }}
                            rowSelection={rowSelection}
                            onHeaderRow={column => {
                                return {
                                    onDoubleClick: () => {
                                        this.feeRef.onOpenModel();
                                    },
                                };
                            }} bordered
                            rowKey={(data) => {
                                return data.tabIndex
                            }}
                            pagination={false}></Table>
                    </Col>
                    <Col style={{ height: '65vh', background: '#f1f2f5' }}>
                        <Card bodyStyle={{ padding: '2px 3px' }} style={{
                            float: 'left', width: '59%', minHeight: '65vh', maxHeight: '70vh'
                        }}>
                            <div style={{ height: 30, lineHeight: '30px', display: 'flex', borderBottom: '1px solid rgb(238, 238, 238)' }}>
                                <span className='collection-list-left'></span>
                                <span style={{ color: '#666666', marginLeft: 10 }}>医嘱清单</span>
                                {/* <span style={{ color: 'red' }}>注：1、黄色为补录；2、灰色背景代表参照医嘱补录;</span> */}
                                <div className='collection-bgd-copy' style={{ marginLeft: 10 }}></div>补录
                                <div className='collection-bgd-card' style={{ marginLeft: 10 }}></div>参照补录
                                <div className='collection-bgd-copyed' style={{ marginLeft: 10 }}></div>被参照
                            </div>

                            <div style={{ marginTop: 5 }}>
                                <span>
                                    医嘱名称：<Input placeholder='请输入医嘱名称回车键查询' style={{ width: '19vh' }}
                                        onKeyDown={this.keyDownInput.bind(this)}
                                        onChange={Util.commonInputChange.bind(this, 'searchCode')} />
                                </span>
                                <span style={{ marginLeft: 5 }}>
                                    开单科室：<Select placeholder='开单科室' style={{ width: '13vh' }} allowClear showSearch
                                        onChange={this.commonSelectOption.bind(this, 'ordLocID')}>{ordLocListOption}</Select>
                                </span>
                                <span style={{ marginLeft: 5 }}>
                                    医嘱类型：<Select placeholder='医嘱类型' style={{ width: '13vh' }} allowClear showSearch
                                        filterOption={(input, option) =>
                                            option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                            || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                        }
                                        onChange={this.commonSelectOption.bind(this, 'priorityID')}>{priorityListOption}</Select>
                                </span>
                                <span style={{ marginLeft: 5 }}>
                                    医嘱状态：<Select placeholder='医嘱状态' style={{ width: '13vh' }} allowClear showSearch
                                        value={this.state.ordStatusID}
                                        filterOption={(input, option) =>
                                            option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                            || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                        }
                                        onChange={this.commonSelectOption.bind(this, 'ordStatusID')}>{ordStatusListOption}</Select>
                                </span><br />
                                <span style={{ marginTop: 5, display: 'flex' }}>
                                    <span style={{ marginTop: 3 }}>处理状态：</span>
                                    <Select placeholder='处理状态' style={{ width: '19vh', marginRight: 5 }}
                                        value={this.state.handlerStatus}
                                        onChange={this.commonSelectOption.bind(this, 'handlerStatus')}>
                                        {handlerStatusListOption}
                                    </Select>
                                    <RangeDatePicker label='医嘱开始时间：' format='YYYY-MM-DD' width={'31vh'}
                                        startDate={this.state.regDateFrom} endDate={this.state.regDateTo}
                                        startChange={this.startChange.bind(this)} endChange={this.endChange.bind(this)} />
                                    <Button style={{ marginLeft: 5 }} type='primary' onClick={this.loadAdviceList.bind(this, '1')}>查询</Button>
                                </span>
                            </div>

                            <div style={{ marginTop: 5 }}>
                                <Table columns={this.state.adviceColumns} dataSource={this.state.adviceData}
                                    className='collection-advice-table'
                                    scroll={{ y: '45vh', x: this.state.adviceWidth }}
                                    rowSelection={rowSelectionList}
                                    rowKey={(data) => {
                                        return data.ordID
                                    }}
                                    onHeaderRow={column => {
                                        return {
                                            onDoubleClick: () => {
                                                this.adviceRef.onOpenModel();
                                            },
                                        };
                                    }}
                                    bordered
                                    onRow={this.onAdviceClickRow}
                                    rowClassName={this.setAdviceRowClassName}
                                    title={() => {
                                        return <div>
                                            <Button style={{ background: '#1999db', color: 'white' }}
                                                className='patient-saveButton' onClick={this.handleDetailMsg.bind(this)}>处理</Button>
                                            <Button style={{ background: '#FA8C16', color: 'white' }}
                                                onClick={this.onSubmitDealAdvice.bind(this, 'cannel')}
                                                className='patient-saveButton'>撤销处理</Button>
                                            <Button style={{ background: '#13C2C2', color: 'white' }}
                                                onClick={this.handleUndoAdvice.bind(this)}
                                                className='patient-saveButton'>撤销补录</Button>
                                        </div>
                                    }}
                                    pagination={false}></Table>
                                <CommonPagination current={this.state.pageLeft} total={this.state.adviceTotal} search={this.state.search}
                                    onShowSizeChange={this.changeLeftPageSize.bind(this)} complete={true} dataSource={this.state.adviceData} pageSize='200' size='large'
                                    loading={this.state.loading} onChange={this.onChangeLeft.bind(this)} />
                            </div>
                        </Card>

                        <Card bodyStyle={{ padding: '2px 3px' }} style={{
                            float: 'right', width: '40.5%', borderLeft: '1px solid #EEEEEE',
                            minHeight: '65vh', maxHeight: '70vh'
                        }}>
                            <div style={{ height: 30, lineHeight: '30px', background: '#F6FCF9' }}>
                                <span className='collection-list-left'></span>
                                <span style={{ color: '#1999db', marginLeft: 10 }}>执行记录</span>
                            </div>
                            <div style={{ display: 'flex', marginTop: 5 }}>
                                <RangeDatePicker format='YYYY-MM-DD' width={'27vh'}
                                    startDate={this.state.dateFrom} endDate={this.state.dateTo}
                                    startChange={this.startChangeDate.bind(this)} endChange={this.endChangeDate.bind(this)} />
                                <Button size='small' style={{ marginLeft: 10 }} onClick={this.loadAdviceCollectionList.bind(this, '1')}>查询</Button>
                                {/* <Button size='small'
                                    style={{ background: Util.isEmpty(this.state.execIDs) ? '' : '#1999db', color: Util.isEmpty(this.state.execIDs) ? '#666666' : 'white', marginLeft: '10px' }}
                                    disabled={Util.isEmpty(this.state.execIDs) ? true : false}
                                    className='patient-saveButton' onClick={this.handleExecList.bind(this, 'F')}>执行</Button> */}
                                <Button size='small' style={{ background: Util.isEmpty(this.state.execIDs) ? '' : '#13C2C2', color: Util.isEmpty(this.state.execIDs) ? '#666666' : 'white', marginLeft: '10px' }}
                                    disabled={Util.isEmpty(this.state.execIDs) ? true : false}
                                    className='patient-saveButton' onClick={this.handleExecList.bind(this, 'CE')}>撤销执行</Button>
                                <Button size='small' style={{ background: Util.isEmpty(this.state.execIDs) ? '' : '#FA8C16', color: Util.isEmpty(this.state.execIDs) ? '#666666' : 'white' }}
                                    disabled={Util.isEmpty(this.state.execIDs) ? true : false}
                                    className='patient-saveButton' onClick={this.handleExecList.bind(this, 'DE')}>停止执行</Button>
                                {this.state.takeFlag == '1' ? <Button size='small' type='primary' disabled={this.state.takeFlag !== 1} onClick={this.handleMedicleMessage.bind(this)}>取药执行记录</Button> :
                                    <Tooltip title='当前医嘱不允许插入取药执行记录！'>
                                        <Button size='small' type='primary' disabled={this.state.takeFlag !== 1} onClick={this.handleMedicleMessage.bind(this)}>取药执行记录</Button></Tooltip>}
                            </div>

                            <div style={{ marginTop: 5 }}>
                                <Table columns={this.state.execuseColumns} dataSource={this.state.collectionData}
                                    style={{ height: '27vh' }} className='coll-context-table'
                                    scroll={{ x: this.state.execuseWidth, y: store.getState().tableHeight.y }}
                                    onRow={this.onExecClickRow}
                                    rowSelection={execRowSelection}
                                    rowClassName={this.setExecRowClassName}
                                    rowKey={(data) => {
                                        return data.ordExecID
                                    }}
                                    onHeaderRow={column => {
                                        return {
                                            onDoubleClick: () => {
                                                this.collectRef.onOpenModel();
                                            },
                                        };
                                    }} bordered
                                    pagination={false}></Table>
                                <CommonPagination
                                    size="large"
                                    current={this.state.pageCon}
                                    pageSize={100}
                                    total={this.state.conTotal}
                                    search={this.state.collSearch}
                                    onShowSizeChange={this.changeConPageSize.bind(this)}
                                    complete={true}
                                    dataSource={this.state.collectionData}
                                    loading={this.state.loading}
                                    onChange={this.onChangeCon.bind(this)}
                                />
                            </div>

                            <div>
                                <div style={{ height: 30, lineHeight: '30px', background: '#F6FCF9' }}>
                                    <span className='collection-list-left'></span>
                                    <span style={{ color: '#1999db', marginLeft: 10 }}>费用明细</span>
                                </div>

                                {/* <div style={{ display: 'flex', marginTop: 5 }}>
                                    <span style={{ marginTop: 3 }}>操作类型：</span><Select style={{ width: '15vh' }} placeholder='请选择操作类型'></Select>
                                    <Button style={{ background: '#13C2C2', color: 'white', marginLeft: '10px' }}
                                        className='patient-saveButton'>撤销补录</Button>
                                </div> */}

                                <div style={{ marginTop: 5 }}>
                                    <Table columns={this.state.chargeColumns} dataSource={this.state.detailData}
                                        scroll={{ x: this.state.chargeWidth, y: 180 }}
                                        onHeaderRow={column => {
                                            return {
                                                onDoubleClick: () => {
                                                    this.detailRef.onOpenModel();
                                                },
                                            };
                                        }} bordered
                                        pagination={false}></Table>
                                </div>

                            </div>
                        </Card>
                    </Col>
                </Row>
            </Card>
        </div>
    }
}

export default CollectionCostsPage;